package org.study;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.junit.After;
import org.junit.Before;

import java.io.IOException;

public class DataDemo {

    Connection connection = null;
    Admin admin = null;

    @Before
    public void connect() throws IOException {
        // 获取HBase的配置
        Configuration conf = HBaseConfiguration.create();
        // 配置zookeeper的连接地址
        conf.set("hbase.zookeeper.quorum", "124.222.134.184");
        conf.set("hbase.zookeeper.property.clientPort", "2181");

//        conf.set("hbase.zookeeper.quorum", "192.168.1.137");
//        conf.set("hbase.zookeeper.property.clientPort", "2181");
        // 发起连接
        Connection connection = ConnectionFactory.createConnection(conf);
        // 获取管理权
        admin = connection.getAdmin();
    }

    @After
    public void close() throws IOException {
        if(null != admin){
            admin.close();
        }
        if(null != connection){
            connection.close();
        }
    }


    // hbase是否有事务？

    // append
    // put
    // scan

}
